// plugin/components/navsearh/navsearh.js
const plugin = require('../../index');
Component({
  behaviors: ['wx://component-export'],
  export () {
    return this
  },
  /**
   * 组件的属性列表
   */
  properties: {
    navshow:{
      type:Boolean,
      observer:function(newVal,oldVal){
        if(newVal!=''){
         // this.showHiddenDict();
         this.setData({
           show:newVal
         })
        }
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    show:false,
    key:'',
    matchlist:[]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    toword(e){
      let item = e.currentTarget.dataset.item;
      console.log(item)
      this.triggerEvent('wordselect',item)
    },
    findInputClear(){
      this.setData({
        key:''
      })
    },
    hide(){
      //组件隐藏

      this.properties.navshow=false
      this.setData({
        show:false,
        key:''
      })
    },
     getinputkey(e){
      this.setData({
        key:e.detail.value
      })
      let word = e.detail.value;
      if(word.length>=4){
        plugin.preMatchWord(word).then(res=>{
          console.log(res)
          this.setData({
            matchlist:res.data
          })
        })
      }
    }
  }
})
